import socket


def client():
    cli = socket.socket()

    cli.connect(("127.0.0.2", 1024))
    cli.send(input('请输入暗号：').encode('utf-8'))
    back = cli.recv(1024).decode('utf-8')
    if back == "欢迎加入群聊":
        print(back)
        while True:
            cli.send(input("请输入:").encode('utf-8'))
            data = cli.recv(1024)
            if not data:
                print("结束回话")
                cli.close()
                break
    else:
        print(back)
        cli.close()

if __name__ == "__main__":
    c = client()


